package com.wen.controller;

import com.wen.pojo.OutStore;
import com.wen.pojo.Store;
import com.wen.service.OutStoreService;
import com.wen.service.ProductService;
import com.wen.utils.PageBean;
import com.wen.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/outstore")
public class OutStoreController {
    @Autowired
    private OutStoreService outStoreService;

    @RequestMapping("/outstore-add")
    public Result addOutStore(@RequestBody OutStore outStore){
        return outStoreService.addCk(outStore);
    }

    //所有仓库信息
    @Autowired
    private ProductService productService;
    @RequestMapping("/store-list")
    public Result allStoreList(){
        List<Store> storeList = productService.findStoreList();
        return Result.ok(200,"查询成功",storeList);
    }

    //分页查询出口单
    @RequestMapping("/outstore-page-list")
    public Result<PageBean<OutStore>> list(Integer pageNum, Integer pageSize, OutStore outStore){
        PageBean<OutStore> outStorePageBean = outStoreService.allList(pageNum, pageSize, outStore);
        return Result.ok(200,"查询成功",outStorePageBean);
    }

    //确定出库
    @RequestMapping("/outstore-confirm")
    private Result outStore(@RequestBody OutStore outStore){
        return outStoreService.outStore(outStore);
    }
}
